<?php
    session_start();; 
	include_once("connection.php");
    
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../css/default.css"/>
<link rel="stylesheet" type="text/css" href="../css/ddsmoothmenu.css"/>

<script src="../js/jquery-1.10.0.js"></script>
<script src="../js/home_menu.js"></script>

<script type="text/javascript">
    ddsmoothmenu.init({
    	mainmenuid: "smoothmenu1", //menu DIV id
    	orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
    	classname: 'ddsmoothmenu', //class added to menu's outer DIV
    	//customtheme: ["#1c5a80", "#18374a"],
    	contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
    })
	
	$(function() {
		$('.banner img:gt(0)').hide();
			setInterval(function(){
			  $('.banner :first-child').fadeOut().next('img').fadeIn().end().appendTo('.banner');}
			  ,4000);
	}); // slide banner

    $(document).ready(function() {
        $('#region_khoa').hide();
        $('#region_lop').hide();
        $('#rdb_truong').focus();
        
        get_list();
    });
    
    function show_khoa() {
        $('#region_khoa').show();
        $('#region_lop').hide();
    }
    function show_lop() {
        $('#region_lop').show();
        $('#region_khoa').hide();        
    }
    function hide_all() {
        $('#region_lop').hide();  
        $('#region_khoa').hide();       
    }
    
    function get_title()
    {
        $.ajax({
            url: "thongke_ajax_title.php",
            type: "POST",
            data: {
                action: "get_title",
                khuvuc: $('input[name=range]:checked').val(),
                hocky: $('#select_hocky').val(),
                khoa: $('#select_khoa').val(),
                lop: $('#select_lop').val(),                
            },
            success: function(result) {
                var data = $.parseJSON(result);
                $('#title_hocky').html(data.hocky);
                $('#title_nam').html(data.nam);
                $('#title_khuvuc').html(data.khuvuc);
                //$('#title_info').html(result);
            }
        });
    }
    
    function get_list()
    {        
        get_title();
        
        $.ajax({
            url: "thongke_ajax_data.php",
            type: "POST",
            data: {
                khuvuc: $('input[name=range]:checked').val(),
                hocky: $('#select_hocky').val(),
                khoa: $('#select_khoa').val(),
                lop: $('#select_lop').val(),
            },
            success: function(result){
                $('#table').html(result);
            }
        });
    }

</script>
<!-- TemplateBeginEditable name="doctitle" -->
<title>Website QLSV va DKMH</title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<!-- TemplateEndEditable -->
</head>

<body>
    <div id="logo">
        <img src="../image/source/logo.png" />
    </div>
    
    <div class="banner">
    	<img src="../image/source/uit1.jpg" width="1000" height="250" />
        <img src="../image/source/uit2.jpg" width="1000" height="250" />
        <img src="../image/source/uit3.jpg" width="1000" height="250" />
        <img src="../image/source/uit4.jpg" width="1000" height="250" />
        <img src="../image/source/uit5.jpg" width="1000" height="250" />
    </div><br/>
    
    <div id="smoothmenu1" class="ddsmoothmenu">
        <ul>
            <li><a href="../">TRANG CHỦ</a></li>
            <li><a href="../">GIẢNG VIÊN</a>
                <ul>
                    <li><a href="../">THỜI KHÓA BIỂU</a></li>
                    <li><a href="../?page=tbnh">NGHỈ - HỌC BÙ</a></li>
                    <li><a href="../?page=ttgv">THÔNG TIN LÝ LỊCH</a></li>
                    <li><a href="../">QUẢN LÝ ĐIỂM</a></li>
                </ul>
            </li>
            
            <li><a href="../">SINH VIÊN</a>
                <ul>
                    <li><a href="../app_sv/tkb_sv.php">THỜI KHÓA BIỂU</a></li>
                    <li><a href="../app_sv/check_dk.php">ĐK MÔN HỌC</a></li>
                    <li><a href="../?page=ttll">THÔNG TIN LÝ LỊCH</a></li>
                    <li><a href="../">KẾT QUẢ HỌC TẬP</a></li>
                </ul>
            </li>            
            <li><a href="app/thongke.php">ĐẦU BẢNG</a></li>
            <li><a href="../?page=tltk">THIẾT LẬP TÀI KHOẢN</a></li>
        </ul>
        <br style="clear: left" />
    </div>
    <!-- TemplateBeginEditable name="content" -->
    <div id="container">      
        <div id="control" style="float: left; width: 260px;">    
            <form  name="form1" method="post" action="" onsubmit="return false;">
                <fieldset>
                    <legend>Phan vung</legend>
                    <input type="radio" name="range" id="rdb_truong" value="toantruong" onclick="hide_all();" checked="checked" />Toan truong<br />
                    <input type="radio" name="range" id="rdb_khoa" value="khoa" onclick="show_khoa();" />Theo khoa<br />
                    <input type="radio" name="range" id="rdb_lop" value="lop" onclick="show_lop();" />Theo lop<br />            
                </fieldset><br />
                
                <fieldset id="region_khoa">
                    <legend>Chon khoa</legend>
                    <select id="select_khoa">
                    <?php
                        $sql = mysql_query("SELECT * FROM khoa");
                        while($rows = mysql_fetch_assoc($sql)) {
                            echo "<option value='".$rows['MAKHOA']."'>".$rows['TENKHOA']."</option>";
                        }
                    ?>
                    </select>
                </fieldset>
                
                <fieldset id="region_lop">
                    <legend>Chon lop</legend>
                    <select id="select_lop">
                    <?php
                        $sql = mysql_query("SELECT MAKHOA, KHOAHOC FROM sinhvien GROUP BY MAKHOA, KHOAHOC 
                            ORDER BY MAKHOA, KHOAHOC DESC");
                        while($rows = mysql_fetch_assoc($sql)) {
                            echo "<option value='".$rows['MAKHOA'].".".$rows['KHOAHOC']."'>".$rows['MAKHOA'].".".$rows['KHOAHOC']."</option>";
                        }
                    ?>
                    </select>
                </fieldset>
                <br />
                <fieldset>
                    <legend>Chon hoc ky</legend>
                    <select id="select_hocky">
                    <?php
                        $today = date("Y-m-d");
                        $sql = mysql_query("SELECT HOCKY,NAM FROM hocky 
                        WHERE NGAYKETTHUC <= '$today'
                        ORDER BY NAM DESC, HOCKY DESC");
                        while($rows = mysql_fetch_assoc($sql)) {
                            echo "<option value='".$rows['HOCKY'].".".$rows['NAM']."'>HK ".$rows['HOCKY'].
                            " - ".$rows['NAM']."</option>";
                        }
                    ?>
                    </select>
                </fieldset><br />
                
                <center><input type="submit" name="" value="Xem thống kê" onclick="get_list()"  />                
            </form></center>
        </div>
        
        <!-- Hien thi danh sach thong ke -->
        <div id="content" style="width: 680px;">
            <center><h3> BẢNG THỐNG KÊ KẾT QUẢ CAO NHẤT </h3>
            
            <h4>HỌC KỲ <span id="title_hocky"></span> 
            - NĂM HỌC <span id="title_nam"></span></h4>
            
            <h4>KHU VỰC: <span id="title_khuvuc"></span></h4></center>
            
            <center><span id="title_info"></span></center>
            
            <center><table class="danhsach" id="table" border="1" style="border-collapse: collapse;">
            
            </table></center>
        </div>
        
        <br />
      <p style="color:#fff;">Design by DK</p>
    </div>
    <!-- TemplateEndEditable --><!--End Container-->

    <div id="footer">
        <div id="contact">
            <?php
                $today = date("d-m-Y");
                echo "Hôm nay: ".$today."<br />";
            ?>
            Liên hệ phòng đào tạo: 
            <ol>
                <li>Địa chỉ: Km20, xa lộ Hà Nội, phường Linh Trung, quận Thủ Đức, Tp Hồ Chí Minh</li>
                <li>Số điện thoại: (08) 37251993 </li>
                <li>Email: uit@uit.edu.vn</li>
                
            </ol>
        </div>
        
        
        <div id="admin">
            <a id="admin-content" href="../admin/ad_login.php" style="font-size:20px; padding-top:10px;">@Bộ phận quản lý</a>
        </div>
    </div>
</body>
</html>





